package com.bachelor.community.utils;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class ExceptionAdvice {

    @ExceptionHandler(Exception.class)
    public Result doException(Exception ex) {
        ex.printStackTrace();
        return Result.fail("500", "服务器故障，请联系管理员");
    }

    @ExceptionHandler(ServiceException.class)
    public Result serviceExceptionHandler(ServiceException se) {
        se.printStackTrace();
        return Result.fail(se.getCode(), se.getMessage());
    }
}
